<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            outline: none;
        }

        body {
            background: linear-gradient(45deg, #fbda61, #f4acd8);
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .shell {
            display: flex;
            justify-content: center;
        }

        form {
            width: 562px;
            height: 520px;
            background-color: #fff;
            box-shadow: 0px 15px 40px #b6354e;
            border-radius: 15px;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #img-box {
            width: 330px;
            height: 520px;
        }

        #img-box img {
            height: 100%;
        }

        #form-body {
            width: 320px;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        #welcome-lines {
            width: 100%;
            text-align: center;
            line-height: 1;
        }

        #w-line-1 {
            color: #7f7f7f;
            font-size: 50px;
        }

        #w-line-2 {
            color: #9c9c9c;
            font-size: 30px;
            margin-top: 17px;
        }

        #input-area {
            width: 100%;
            margin-top: 40px;
        }

        .f-inp {
            padding: 13px 25px;
            border: 2px solid #6e6d6d;
            line-height: 1;
            border-radius: 20px;
            margin-bottom: 15px;
        }

        .f-inp input {
            width: 100%;
            font-size: 14px;
            padding: 0;
            margin: 0;
            border: 0;
        }

        .f-inp input::placeholder {
            color: #b9b9b9;
        }

        #submit-button-cvr {
            margin-top: 20px;
        }

        #submit-button {
            display: block;
            width: 100%;
            color: #fff;
            font-size: 14px;
            margin: 0;
            padding: 14px 40px;
            border: 0;
            background-color: #f5506e;
            border-radius: 25px;
            line-height: 1;
            cursor: pointer;
        }

        #forgot-pass {
            text-align: center;
            margin-top: 10px;
        }

        #forgot-pass a {
            color: #868686;
            font-size: 12px;
            text-decoration: none;
        }

        #headerBar {
            display: none;
        }
    </style>
</head>

<body>
    <div class="login">
        <div class="shell">
            <div id="img-box">
                <img src="./static/1.png" alt="">
            </div>
            <form action="/login" method="post" id="login">
                <div id="form-body">
                    <div id="welcome-lines">
                        <div id="w-line-1">VMBOX</div>
                    </div>
                    {% csrf_token %}
                    <input type="hidden" name="next" value="/virt/domain">
                    <div id="input-area">
                        <div class="f-inp">
                            <input type="text" name="username" placeholder="UserName">
                        </div>
                        <div class="f-inp">
                            <div class="password">
                                <input type="password" name="password" placeholder="Password">
                            </div>
                        </div>
                    </div>
                    <div id="submit-button-cvr">
                        <button type="button" id="submit-button" onclick="login(this)">登录</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</body>

<script src="/static/jquery/jquery-3.7.1-dev.js"></script>
<script>
    function login(e) {
       form = new FormData(document.getElementById("login"));
       user = form.get("username");
       password = form.get("password"); 
       if(user == '' || password == ''){
        return;
       }
       $.post("/login", {"username": user, "password": password}, function(data,status){
            if(data["status"] == "success"){
                window.location.href = "/"
            }else{
                alert("认证失败!");
            }
       })
    }
    document.addEventListener("keyup", function(e){
        if(e.keyCode == 13){
            login()
        }
    })
</script>
</html>

